package limeirafol.gui.financeiro;

import lbframework.bean.internalFrame.LBInternalFrame;
import lbframework.bean.mdiFrame.LBMdiFrame;
import lbframework.classe.Util;
import limeirafol.Global;
import limeirafol.bean.BeanFinanceiro;
import limeirafol.remote.financeiro.ChequesRecebidosVO;
import limeirafol.remote.financeiro.SituacaoChequeRecebido;

public class ChequesRecebidosCadastroGUI extends LBInternalFrame {

    public ChequesRecebidosVO oCheque = new ChequesRecebidosVO();
    BeanFinanceiro beanFinanceiro = new BeanFinanceiro();

    public ChequesRecebidosCadastroGUI(LBMdiFrame i_mdiFrame) throws Exception {
        super(i_mdiFrame);
        initComponents();

        centralizarForm();

        txtDataLancamento.setText(Global.getDataProcessamento());
        txtBomPara.setText(Global.getDataProcessamento());

        cboSituacao.setTabela("situacaocheque");
        cboSituacao.carregar();
        cboSituacao.setId(1);
        cboSituacao.setEnabled(false);

        verificaSituacaoCheque();

    }

    @Override
    public void salvar() throws Exception {

        oCheque.dataLancamento = Util.formatDataBanco(txtDataLancamento.getText());
        oCheque.numeroCheque = txtNumeroCheque.getLong();
        oCheque.descricao = txtDescricao.getText();
        oCheque.bomPara = chkCehquePre.isSelected();
        oCheque.dataBomPara = Util.formatDataBanco(txtBomPara.getText());
        oCheque.observacoes = txtObservacoes.getText();
        oCheque.idSituacaoCheque = cboSituacao.getId();
        oCheque.valor = txtValor.getDouble();

        beanFinanceiro.salvarChequeRecebido(oCheque);

        Util.exibirMensagem(Util.MSG_SALVO_SUCESSO, getTitle());

        getEstadoTelaInicial();

    }

    public void carregarChequeRecebido(int i_id) throws Exception {
        oCheque = beanFinanceiro.carregarChequeRecebido(i_id);

        txtDataLancamento.setText(oCheque.dataLancamento);
        txtNumeroCheque.setText(Util.formatNumber(oCheque.numeroCheque, 8));
        txtDescricao.setText(oCheque.descricao);
        chkCehquePre.setSelected(oCheque.bomPara);
        txtBomPara.setText(oCheque.dataBomPara);
        txtObservacoes.setText(oCheque.observacoes);
        cboSituacao.setId(oCheque.idSituacaoCheque);
        txtValor.setDouble(oCheque.valor);

        verificaSituacaoCheque();

        getEstadoTelaInicial();

    }

    public void verificaSituacaoCheque() throws Exception {
        if (cboSituacao.getId() == SituacaoChequeRecebido.ABERTO.getId()) {
            btnEstornar.setEnabled(false);
            btnDepositar.setEnabled(true);
            btnReceber.setEnabled(false);
            btnDevolvido.setEnabled(false);
            btnDevolvidoCliente.setEnabled(true);
            txtDescricao.setEnabled(true);
            txtNumeroCheque.setEnabled(true);
            txtValor.setEnabled(true);
            chkCehquePre.setEnabled(true);
        }
        if (cboSituacao.getId() == SituacaoChequeRecebido.DEPOSITADO.getId()) {
            btnEstornar.setEnabled(true);
            btnDepositar.setEnabled(false);
            btnReceber.setEnabled(true);
            btnDevolvido.setEnabled(true);
            btnDevolvidoCliente.setEnabled(false);
            txtValor.setEnabled(false);
            txtDescricao.setEnabled(false);
            txtNumeroCheque.setEnabled(false);
            chkCehquePre.setEnabled(false);
            txtBomPara.setEnabled(false);

        }
        if (cboSituacao.getId() == SituacaoChequeRecebido.RECEBIDO.getId()) {
            btnEstornar.setEnabled(true);
            btnDepositar.setEnabled(false);
            btnReceber.setEnabled(false);
            btnDevolvido.setEnabled(false);
            btnDevolvidoCliente.setEnabled(false);
            txtDescricao.setEnabled(false);
            txtNumeroCheque.setEnabled(false);
            chkCehquePre.setEnabled(false);
            txtBomPara.setEnabled(false);
            txtValor.setEnabled(false);
        }
        if (cboSituacao.getId() == SituacaoChequeRecebido.DEVOLVIDO.getId()) {
            btnEstornar.setEnabled(false);
            btnDepositar.setEnabled(true);
            btnReceber.setEnabled(false);
            btnDevolvido.setEnabled(false);
            btnDevolvidoCliente.setEnabled(true);
            txtDescricao.setEnabled(false);
            txtNumeroCheque.setEnabled(false);
            chkCehquePre.setEnabled(false);
            txtBomPara.setEnabled(false);
            txtValor.setEnabled(false);
        }
        if (cboSituacao.getId() == SituacaoChequeRecebido.DEVOLVIDO_CLIENTE.getId()) {
            btnEstornar.setEnabled(true);
            btnDepositar.setEnabled(false);
            btnReceber.setEnabled(false);
            btnDevolvido.setEnabled(false);
            btnDevolvidoCliente.setEnabled(false);
            txtDescricao.setEnabled(false);
            txtNumeroCheque.setEnabled(false);
            chkCehquePre.setEnabled(false);
            txtBomPara.setEnabled(false);
            txtValor.setEnabled(false);
        }

        if (cboSituacao.getId() == SituacaoChequeRecebido.EXCLUIDO.getId()) {
            btnEstornar.setEnabled(true);
            btnDepositar.setEnabled(false);
            btnReceber.setEnabled(false);
            btnDevolvido.setEnabled(false);
            btnDevolvidoCliente.setEnabled(false);
            txtDescricao.setEnabled(false);
            txtNumeroCheque.setEnabled(false);
            txtValor.setEnabled(false);
            chkCehquePre.setEnabled(false);
            txtBomPara.setEnabled(false);
            txtObservacoes.setEnabled(false);
        }

    }

    public void alterarSituacaoChequeDepositar() throws Exception {
        Util.exibirMensagemConfirmar("Confirma Depósito do cheque " + oCheque.numeroCheque + " ?", getTitle());

        beanFinanceiro.alterarSituacaoCheque(oCheque.id, SituacaoChequeRecebido.DEPOSITADO.getId());
        carregarChequeRecebido(oCheque.id);

    }

    public void alterarSituacaoChequeReceber() throws Exception {
        Util.exibirMensagemConfirmar("Confirma o Recebimento referente ao valor do cheque " + oCheque.numeroCheque + " ?", getTitle());

        beanFinanceiro.alterarSituacaoCheque(oCheque.id, SituacaoChequeRecebido.RECEBIDO.getId());
        carregarChequeRecebido(oCheque.id);

    }

    public void alterarSituacaoChequeEstornar() throws Exception {
        Util.exibirMensagemConfirmar("Confirma o estorno do cheque " + oCheque.numeroCheque + " ?", getTitle());

        beanFinanceiro.alterarSituacaoCheque(oCheque.id, SituacaoChequeRecebido.ABERTO.getId());
        carregarChequeRecebido(oCheque.id);

    }

    public void alterarSituacaoChequeDevolvido() throws Exception {
        Util.exibirMensagemConfirmar("Confirma a devolução do cheque " + oCheque.numeroCheque + " ?", getTitle());

        beanFinanceiro.alterarSituacaoCheque(oCheque.id, SituacaoChequeRecebido.DEVOLVIDO.getId());
        carregarChequeRecebido(oCheque.id);

    }

    public void alterarSituacaoChequeDevolvidoCliente() throws Exception {
        Util.exibirMensagemConfirmar("Confirma a devolução do cheque " + oCheque.numeroCheque + " ao cliente?", getTitle());

        beanFinanceiro.alterarSituacaoCheque(oCheque.id, SituacaoChequeRecebido.DEVOLVIDO_CLIENTE.getId());
        carregarChequeRecebido(oCheque.id);

    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lBPanel1 = new lbframework.bean.panel.LBPanel();
        txtDataLancamento = new lbframework.bean.textField.LBTextField();
        lBLabel6 = new lbframework.bean.label.LBLabel();
        txtNumeroCheque = new lbframework.bean.textField.LBTextField();
        lBLabel7 = new lbframework.bean.label.LBLabel();
        lBLabel8 = new lbframework.bean.label.LBLabel();
        txtDescricao = new lbframework.bean.textField.LBTextField();
        lBLabel9 = new lbframework.bean.label.LBLabel();
        txtBomPara = new lbframework.bean.textField.LBTextField();
        chkCehquePre = new lbframework.bean.checkBox.LBCheckBox();
        cboSituacao = new lbframework.bean.comboBox.LBComboBox();
        lBLabel10 = new lbframework.bean.label.LBLabel();
        txtValor = new lbframework.bean.textField.LBTextField();
        lBLabel11 = new lbframework.bean.label.LBLabel();
        lBPanel2 = new lbframework.bean.panel.LBPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtObservacoes = new lbframework.bean.textArea.LBTextArea();
        lBPanel3 = new lbframework.bean.panel.LBPanel();
        lBButton1 = new lbframework.bean.button.LBButton();
        lBButton2 = new lbframework.bean.button.LBButton();
        lBToolBar1 = new lbframework.bean.toolBar.LBToolBar();
        lBToolBarPadrao1 = new lbframework.bean.toolBarPadrao.LBToolBarPadrao(this);
        btnEstornar = new lbframework.bean.button.LBButton();
        btnDepositar = new lbframework.bean.button.LBButton();
        btnReceber = new lbframework.bean.button.LBButton();
        btnDevolvido = new lbframework.bean.button.LBButton();
        btnDevolvidoCliente = new lbframework.bean.button.LBButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Cadastro de Cheques Recebidos");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/cheque.png"))); // NOI18N
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameClosing(evt);
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        txtDataLancamento.setEnabled(false);
        txtDataLancamento.setMascara("Data");

        lBLabel6.setText("Data");

        txtNumeroCheque.setColumns(15);
        txtNumeroCheque.setMascara("Numero");
        txtNumeroCheque.setObrigatorio(true);
        txtNumeroCheque.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtNumeroChequeFocusLost(evt);
            }
        });

        lBLabel7.setText("Nro. Cheque");

        lBLabel8.setText("Descrição");

        txtDescricao.setColumns(50);
        txtDescricao.setObrigatorio(true);

        lBLabel9.setText("Bom Para");

        txtBomPara.setEnabled(false);
        txtBomPara.setMascara("Data");

        chkCehquePre.setText("Cheque Pré");
        chkCehquePre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkCehquePreActionPerformed(evt);
            }
        });

        lBLabel10.setText("Situação");

        txtValor.setColumns(15);
        txtValor.setMascara("Decimal 2");
        txtValor.setObrigatorio(true);

        lBLabel11.setText("Valor");

        javax.swing.GroupLayout lBPanel1Layout = new javax.swing.GroupLayout(lBPanel1);
        lBPanel1.setLayout(lBPanel1Layout);
        lBPanel1Layout.setHorizontalGroup(
            lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(lBPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtDataLancamento, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lBLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lBLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNumeroCheque, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lBLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(4, 4, 4)
                .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lBLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtValor, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chkCehquePre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtBomPara, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lBLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lBLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cboSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        lBPanel1Layout.setVerticalGroup(
            lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(lBPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(lBPanel1Layout.createSequentialGroup()
                        .addComponent(lBLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtValor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(lBPanel1Layout.createSequentialGroup()
                        .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lBLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lBLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(chkCehquePre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtBomPara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cboSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(lBPanel1Layout.createSequentialGroup()
                        .addComponent(lBLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(lBPanel1Layout.createSequentialGroup()
                        .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lBLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lBLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtDataLancamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtNumeroCheque, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        lBPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Observações"));

        txtObservacoes.setColumns(20);
        txtObservacoes.setRows(5);
        jScrollPane1.setViewportView(txtObservacoes);

        javax.swing.GroupLayout lBPanel2Layout = new javax.swing.GroupLayout(lBPanel2);
        lBPanel2.setLayout(lBPanel2Layout);
        lBPanel2Layout.setHorizontalGroup(
            lBPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 805, Short.MAX_VALUE)
        );
        lBPanel2Layout.setVerticalGroup(
            lBPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)
        );

        lBButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/sair.png"))); // NOI18N
        lBButton1.setText("Sair");
        lBButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lBButton1ActionPerformed(evt);
            }
        });

        lBButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/salvar.png"))); // NOI18N
        lBButton2.setText("Salvar");
        lBButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lBButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout lBPanel3Layout = new javax.swing.GroupLayout(lBPanel3);
        lBPanel3.setLayout(lBPanel3Layout);
        lBPanel3Layout.setHorizontalGroup(
            lBPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, lBPanel3Layout.createSequentialGroup()
                .addContainerGap(645, Short.MAX_VALUE)
                .addComponent(lBButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lBButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        lBPanel3Layout.setVerticalGroup(
            lBPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(lBPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(lBButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(lBButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        lBToolBar1.setRollover(true);

        lBToolBarPadrao1.setRollover(true);
        lBToolBarPadrao1.setVisibleIncluir(true);
        lBToolBarPadrao1.setVisibleSalvar(true);
        lBToolBar1.add(lBToolBarPadrao1);

        btnEstornar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/estornar.png"))); // NOI18N
        btnEstornar.setToolTipText("Estornar");
        btnEstornar.setFocusable(false);
        btnEstornar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnEstornar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnEstornar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEstornarActionPerformed(evt);
            }
        });
        lBToolBar1.add(btnEstornar);

        btnDepositar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/descer.png"))); // NOI18N
        btnDepositar.setToolTipText("Depositar");
        btnDepositar.setFocusable(false);
        btnDepositar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnDepositar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnDepositar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDepositarActionPerformed(evt);
            }
        });
        lBToolBar1.add(btnDepositar);

        btnReceber.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/recibo.png"))); // NOI18N
        btnReceber.setToolTipText("Receber");
        btnReceber.setFocusable(false);
        btnReceber.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnReceber.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnReceber.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReceberActionPerformed(evt);
            }
        });
        lBToolBar1.add(btnReceber);

        btnDevolvido.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/retornar.png"))); // NOI18N
        btnDevolvido.setToolTipText("Devolvido");
        btnDevolvido.setFocusable(false);
        btnDevolvido.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnDevolvido.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnDevolvido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDevolvidoActionPerformed(evt);
            }
        });
        lBToolBar1.add(btnDevolvido);

        btnDevolvidoCliente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/encaminhar.png"))); // NOI18N
        btnDevolvidoCliente.setToolTipText("Devolvido Cliente");
        btnDevolvidoCliente.setFocusable(false);
        btnDevolvidoCliente.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnDevolvidoCliente.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnDevolvidoCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDevolvidoClienteActionPerformed(evt);
            }
        });
        lBToolBar1.add(btnDevolvidoCliente);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lBPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(lBPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(lBPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addComponent(lBToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 419, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(lBToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lBPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lBPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lBPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void chkCehquePreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkCehquePreActionPerformed
        try {
            if (chkCehquePre.isSelected()) {
                txtBomPara.setEnabled(true);
                txtBomPara.setObrigatorio(true);
                txtBomPara.setText("");
            } else {
                txtBomPara.setEnabled(false);
                txtBomPara.setObrigatorio(false);
                txtBomPara.setText(Global.getDataProcessamento());
            }
        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }

    }//GEN-LAST:event_chkCehquePreActionPerformed

    private void lBButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lBButton1ActionPerformed
        try {
            verificarAlteracaoTela();
            sair();

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }
    }//GEN-LAST:event_lBButton1ActionPerformed

    private void lBButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lBButton2ActionPerformed

        try {
            salvar();
        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }

    }//GEN-LAST:event_lBButton2ActionPerformed

    private void btnDepositarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDepositarActionPerformed

        try {
            alterarSituacaoChequeDepositar();
        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }

    }//GEN-LAST:event_btnDepositarActionPerformed

    private void btnReceberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReceberActionPerformed
        try {
            alterarSituacaoChequeReceber();
        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }
    }//GEN-LAST:event_btnReceberActionPerformed

    private void btnDevolvidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDevolvidoActionPerformed

        try {
            alterarSituacaoChequeDevolvido();
        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }

    }//GEN-LAST:event_btnDevolvidoActionPerformed

    private void btnDevolvidoClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDevolvidoClienteActionPerformed

        try {
            alterarSituacaoChequeDevolvidoCliente();
        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }

    }//GEN-LAST:event_btnDevolvidoClienteActionPerformed

    private void btnEstornarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEstornarActionPerformed

        try {
            alterarSituacaoChequeEstornar();
        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }

    }//GEN-LAST:event_btnEstornarActionPerformed

    private void txtNumeroChequeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtNumeroChequeFocusLost

        txtNumeroCheque.setText(Util.formatNumber(txtNumeroCheque.getText(), 8));

    }//GEN-LAST:event_txtNumeroChequeFocusLost

    private void formInternalFrameClosing(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosing
        try {
            verificarAlteracaoTela();
            sair();

        } catch (Exception e) {
            Util.exibirMensagemErro(e, getTitle());
        }
    }//GEN-LAST:event_formInternalFrameClosing
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private lbframework.bean.button.LBButton btnDepositar;
    private lbframework.bean.button.LBButton btnDevolvido;
    private lbframework.bean.button.LBButton btnDevolvidoCliente;
    private lbframework.bean.button.LBButton btnEstornar;
    private lbframework.bean.button.LBButton btnReceber;
    private lbframework.bean.comboBox.LBComboBox cboSituacao;
    private lbframework.bean.checkBox.LBCheckBox chkCehquePre;
    private javax.swing.JScrollPane jScrollPane1;
    private lbframework.bean.button.LBButton lBButton1;
    private lbframework.bean.button.LBButton lBButton2;
    private lbframework.bean.label.LBLabel lBLabel10;
    private lbframework.bean.label.LBLabel lBLabel11;
    private lbframework.bean.label.LBLabel lBLabel6;
    private lbframework.bean.label.LBLabel lBLabel7;
    private lbframework.bean.label.LBLabel lBLabel8;
    private lbframework.bean.label.LBLabel lBLabel9;
    private lbframework.bean.panel.LBPanel lBPanel1;
    private lbframework.bean.panel.LBPanel lBPanel2;
    private lbframework.bean.panel.LBPanel lBPanel3;
    private lbframework.bean.toolBar.LBToolBar lBToolBar1;
    private lbframework.bean.toolBarPadrao.LBToolBarPadrao lBToolBarPadrao1;
    private lbframework.bean.textField.LBTextField txtBomPara;
    private lbframework.bean.textField.LBTextField txtDataLancamento;
    private lbframework.bean.textField.LBTextField txtDescricao;
    private lbframework.bean.textField.LBTextField txtNumeroCheque;
    private lbframework.bean.textArea.LBTextArea txtObservacoes;
    private lbframework.bean.textField.LBTextField txtValor;
    // End of variables declaration//GEN-END:variables
}
